/**
 * @module  我的
 * @author xiongsha
 * @date 2020-12-21 21:31:01
 */

import React, { useState, useEffect } from 'react';
import HeaderComponent from '@src/pages/components/Header';
import { Link } from 'react-router-dom';
import { Toast, List } from 'antd-mobile';
import request from '@src/utils/request';
import { RouteComponentProps, withRouter } from 'react-router';
import moment, { min } from 'moment';
import './index.less';

const { Item } = List;
interface ILevels {
  begin_at?: string;
  content?: string;
  end_at?: string;
  name?: string;
}
interface IMine {
  account?: string;
  avatar?: string;
  bound_phone?: boolean;
  bound_wechat?: boolean;
  nickname?: string;
  levels?: ILevels[];
}

interface IMineCon extends RouteComponentProps {
  mine: IMine;
}
const MineContent: React.FC<IMineCon> = (props) => {
  const { mine } = props;

  const goVip = () => {
    // 去VIP列表页
    localStorage.setItem('vipList', JSON.stringify(mine.levels));
    props.history.push('/vip/list');
  };
  return (
    <div className="mine">
      <HeaderComponent text="我的" />
      <div className="header-con">
        <img className="user-img" src={mine.avatar} alt="" />
        <p>{mine.nickname}</p>
      </div>
      <List renderHeader={() => '基本信息'} className="my-list">
        <Item extra={<Link to="/balance">{mine.account}元</Link>}>余额</Item>
        <Item arrow="horizontal" onClick={goVip}>
          我的会员卡
        </Item>
      </List>
    </div>
  );
};

export default withRouter(MineContent);
